//
//  HAODE
//
//  Created by panquanReabam.com on 15/9/23.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "BusinessCheckVouchDetailViewController.h"
#import "ZJSwitch.h"
#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "UIImageView+WebCache.h"
#import "daogouview.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "shouyinCell.h"
#import "huiyuandengjiViewController.h"
#import "shangpingview.h"
#import "peisongleibieViewController.h"
#import "ToResiduePayViewController.h"
#import "addhuiyuanViewController.h"
#import "huiyuanDetailsViewController.h"
#import "BusinessCouponDetailViewController.h"
#import "saoyisaoViewController.h"
#import "BusinessMemberAddressViewController.h"
#import "BusinessCheckVouchContinueViewController.h"
#import "PlatformProductTypeListViewController.h"
#import "PlaceOrderViewController.h"
@interface BusinessCheckVouchDetailViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,UISearchBarDelegate,UIScrollViewDelegate>
@property (strong, nonatomic) UIScrollView * scrollView;
@property (strong, nonatomic) NSString*GuideCode;
@property (strong, nonatomic) NSString*whsInTypeCode;
@property (strong, nonatomic) NSString*whsId;
@property (strong, nonatomic) NSString*WhsInType;


@end

@implementation BusinessCheckVouchDetailViewController

{
    UISearchBar *search;
    HAODEsingleton* commdity;
    UIButton* sxBtn;
    UIButton*jiantouBtn;
    UIButton*cardBtn;
    float lastContentOffset;
    UITextField*searchTextField;
    UITextField*zhekoujineTextFied;
    UITextField*songhuoTextFied;
    UITextField*anzhuangTextFied;
    UIButton*daogouname;
    daogouview*daogouView;
    UIButton*leixingBtn;
    UIButton*leixingBtn1;
    UIView*shoushiview;
    UIView*view;
    UIView*view1;
    shangpingview*shangpingView;
    UIScrollView*mainScroll;
    UIScrollView*MYmainScroll;
    
      UIScrollView*MYmainScroll1;
      UIScrollView*MYmainScroll2;
    
       NSMutableArray* arrrss2;
       NSMutableArray* arrrss3;
    UILabel*huiyuanname;
    UIButton *tureBtn;
    UILabel*dingdanhao1;
    BOOL saveAccount;
    UIButton *xuanze;
    UIButton*jiagemingxi1;
    UIButton*DiscountRateSatBtn;
    NSMutableArray* arrrss;
    NSMutableArray* arrrss1;
    NSMutableArray*DiscountRatecode ;
    NSMutableArray*DiscountRatecontent ;
    ZJSwitch *switch2;
    UITextField*dinjinjineTextFied;
    UIButton*EarnestRateSatBtn;
    UILabel* weightke;
    UIView*view2;
    UIView*view3;
    UIView*view4;
    UIView*view5;
    UIView*view6;
    UITextView* tv;
    UILabel * label;
    UIImageView*imagess;
    UILabel*shengyuzhifujiage1;
    UIButton*anzhuangSatBtn;
    UIButton*peisongSatBtn;
    UIView* myToolBar;
    UIButton*hejiMoney;
    UIButton* bu;
    UIButton* bu1;
    UIButton* bu2;
    UILabel* shelfNo;
    UIButton*i12;
    UILabel*isActive;
}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    //   [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    
    self.title = self.titleName;
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    

    
     saveAccount=NO;
}



-(void)xuanze:(UIButton*)sender{
    
     [i12 removeFromSuperview];
    
    if (!saveAccount) {
     
       
    
    
    if ([commdity.payStatuss isEqualToString:@"Y"]) {
        [sxBtn removeFromSuperview];
        sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
        [sxBtn setTitle:@"   " forState:UIControlStateNormal];
        [sxBtn setTitleColor:luseColor forState:UIControlStateNormal];
        sxBtn.titleLabel.font=[UIFont systemFontOfSize:28];
        [sxBtn addTarget:self action:@selector(xuanze:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
        self.navigationItem.rightBarButtonItem = myBtnBtn;
    }else{
    
    
    
  
    shoushiview=[[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight)];
    shoushiview.backgroundColor=[UIColor clearColor];
    [self.view addSubview:shoushiview];
    // 手势
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [shoushiview addGestureRecognizer:singleFingerOne];

      
    i12=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-168/2, 0, 168/2, 220*ScreenHeight/1334)];
    i12.backgroundColor=[UIColor colorWithRed:90/255.0 green:130/255.0 blue:26/255.0 alpha:1.0];
    [i12 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    i12.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    [i12 addTarget:self action:@selector(anzhuangqueren:) forControlEvents:UIControlEventTouchUpInside];
    [i12 setTitle:@"继续盘点" forState:UIControlStateNormal];
    [shoushiview addSubview:i12];
    
    if ([commdity.payStatuss isEqualToString:@"Y"]) {
        
        
        [i12 setTitleColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.28] forState:UIControlStateNormal];
    }else{
        
        if ([commdity.payStatuss isEqualToString:@"C"]) {
            [i12 setTitleColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.28] forState:UIControlStateNormal];
        }
        
        
    }
    }
        
           saveAccount=YES;
    }else{
    
    
    saveAccount=NO;}
}

-(void)anzhuangqueren:(UIButton*)sender{
    [i12 removeFromSuperview];
    [shoushiview removeFromSuperview];
    saveAccount=NO;
    
    
    if ([commdity.payStatuss isEqualToString:@"Y"]) {
        
        [self showAlertMessage:@"此订单已经盘点！"];
        
        
    }else{
        if ([commdity.payStatuss isEqualToString:@"C"]) {
            
            [self showAlertMessage:@"此订单已经取消！"];
            
            
        }else {
            
            
            commdity.gengxin=@"Continue";
            PlaceOrderViewController *detailViewController = [[PlaceOrderViewController alloc] init];
            detailViewController.ptype=@"saleItem";
            detailViewController.Whs=@"Continue";
            detailViewController.ckvId=commdity.orderId;
            detailViewController.ckvNo=shelfNo.text;
            detailViewController.whsName=[commdity.Dict objectForKey:@"whsName"];
//            detailViewController.saveTypeStr=@"CHECKVOUCH";
            detailViewController.itemTypeName=[commdity.Dict objectForKey:@"itemTypeName"];
            detailViewController.whsId=[commdity.Dict objectForKey:@"whsId"];
            detailViewController.itemTypeCode=[commdity.Dict objectForKey:@"itemTypeCode"];
            [self.navigationController pushViewController:detailViewController animated:YES];

            
        }
        
    }
    
}


- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
    
    commdity=[HAODEsingleton shared];
    
   
    
    [self jiazaishuju];
    
    
}

-(void)jiazaishuju{
    
    
    self.view.backgroundColor=zuiqianhuicolor;
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:commdity.orderId forKey:@"ckvId"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"-----------%@", param);
    
    [HttpRequest requestData:@"Business/CheckVouch/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
              
                
                commdity.Dict=severDataDict.dataDict;
                
                view1=[[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, 70)];
                view1.backgroundColor=[UIColor whiteColor];
                [self.view addSubview:view1];
                
                
                
                NSString *s2 =[severDataDict.dataDict objectForKey:@"ckvNo"];
                UIFont *font2 = [UIFont systemFontOfSize:17];
                CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
                
                shelfNo=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, labelsize2.width+5, 17)];
                shelfNo.text=[severDataDict.dataDict objectForKey:@"ckvNo"];
                shelfNo.textColor=[UIColor blackColor];
                shelfNo.font=[UIFont systemFontOfSize:17];
                [view1 addSubview:shelfNo];
                
               isActive=[[UILabel alloc]initWithFrame:CGRectMake(shelfNo.right, 15, 45, 17)];
                if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"Y"]) {
                    
                    
                    
                    [isActive setTextColor:luseColor];
                    isActive.text=@"已确认";
                    
                }
                if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"N"]) {
                    
                    [isActive setTextColor:shenhongsecolor];
                    
                    isActive.text=@"未确认";
                    
                    
                }
                if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"C"]) {
                    
                    [isActive setTextColor:hongsecolor];
                    
                    isActive.text=@"已取消";
                    
                    
                }
                commdity.payStatuss= [severDataDict.dataDict objectForKey:@"ckvStatus"];
                isActive.font= [UIFont systemFontOfSize:14];
                isActive.textAlignment=NSTextAlignmentCenter;
                if ([commdity.payStatuss isEqualToString:@"N"]) {
                    [sxBtn removeFromSuperview];
                    sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
                    [sxBtn setBackgroundImage:[UIImage imageNamed:@"gengduodian"]  forState:UIControlStateNormal];
                    [sxBtn addTarget:self action:@selector(xuanze:) forControlEvents:UIControlEventTouchUpInside];
                    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
                    self.navigationItem.rightBarButtonItem = myBtnBtn;
                    

                }
                [view1 addSubview:isActive];
                
                
                
                
                UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 70, ScreenWidth, 0.35)];
                line1.backgroundColor=qianhuicolor;
                [view1 addSubview:line1];
                UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 85/2, 33, contenfot)];
                duogou.text=[NSString stringWithFormat:@"员工"];
                duogou.textColor=zhonghuiColor;
                duogou.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:duogou];
                
                
                
                
                NSString *createName1 = [severDataDict.dataDict objectForKey:@"userName"];
                UIFont *createNamefont1 = [UIFont systemFontOfSize:contenfot];
                CGSize createNamesize1 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize createNamelabelsize1 = [createName1 sizeWithFont:createNamefont1 constrainedToSize:createNamesize1 lineBreakMode:NSLineBreakByCharWrapping];
                
                daogouname=[[UIButton alloc]initWithFrame:CGRectMake(duogou.right, 85/2,createNamelabelsize1.width+15,contenfot)];
                [daogouname setTitle:createName1 forState:UIControlStateNormal];
                daogouname.titleLabel.font=[UIFont systemFontOfSize:contenfot];
                daogouname.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
                //[daogouname addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
                [daogouname setTitleColor:shenhuicolor forState:UIControlStateNormal];
                [view1 addSubview:daogouname];

                
                
                
                UILabel* orderDate=[[UILabel alloc]initWithFrame:CGRectMake(daogouname.right, 85/2, 33, contenfot)];
                orderDate.text=@"日期";
                orderDate.textColor=zhonghuiColor;
                orderDate.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:orderDate];
                NSRange range={0,10};
                NSString* string =[[severDataDict.dataDict  objectForKey:@"createDate"] substringWithRange:range];
                UILabel* orderDate1=[[UILabel alloc]initWithFrame:CGRectMake(orderDate.right, 85/2, 180, contenfot)];
                orderDate1.text=string;
                orderDate1.textColor=shenhuicolor;
                orderDate1.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:orderDate1];
       
                view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 175/2)];
                view2.backgroundColor=[UIColor whiteColor];
                view2.layer.borderWidth = 0.35;
                view2.layer.borderColor = qianhuicolor.CGColor;
                [self.view addSubview:view2];
                
                UILabel *line3=[[UILabel alloc] initWithFrame:CGRectMake(15,  175/2/2, ScreenWidth-30, 0.35)];
                line3.backgroundColor=qianhuicolor;
                [view2 addSubview:line3];
                UILabel*leixing=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 175/2/2)];
                leixing.text=@"类型";
                leixing.textColor=zhonghuiColor;
                leixing.font=[UIFont systemFontOfSize:conten14fot];
                [view2 addSubview:leixing];
                leixingBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,175/2/2)];
                leixingBtn.titleLabel.font=[UIFont systemFontOfSize:conten14fot];
                [leixingBtn setTitle:[severDataDict.dataDict objectForKey:@"itemTypeName"] forState:UIControlStateNormal];
                
                leixingBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
                
                [leixingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [view2 addSubview:leixingBtn];
                
                UILabel*leixing1=[[UILabel alloc]initWithFrame:CGRectMake(15,175/2/2, 200, 175/2/2)];
                leixing1.text=@"仓库";
                leixing1.textColor=zhonghuiColor;
                leixing1.font=[UIFont systemFontOfSize:conten14fot];
                [view2 addSubview:leixing1];
                
                leixingBtn1=[[UIButton alloc]initWithFrame:CGRectMake(30,  175/2/2, ScreenWidth-50,175/2/2)];
                [leixingBtn1 setTitle:[severDataDict.dataDict objectForKey:@"whsName"] forState:UIControlStateNormal];
                leixingBtn1.titleLabel.font=[UIFont systemFontOfSize:conten14fot];
                leixingBtn1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
                [leixingBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [view2 addSubview:leixingBtn1];
                
                [self addd];

                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight-320)];
    [MYmainScroll setBackgroundColor: zuiqianhuicolor];
    MYmainScroll.delegate = self;
    MYmainScroll.userInteractionEnabled = YES;
    MYmainScroll.scrollEnabled = YES;
    MYmainScroll.showsVerticalScrollIndicator = FALSE;
    MYmainScroll.showsHorizontalScrollIndicator = FALSE;
   
    MYmainScroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(ScreenWidth,0, ScreenWidth, ScreenHeight-320)];
    [MYmainScroll1 setBackgroundColor: zuiqianhuicolor];
    MYmainScroll1.delegate = self;
    MYmainScroll1.userInteractionEnabled = YES;
    MYmainScroll1.scrollEnabled = YES;
    MYmainScroll1.showsVerticalScrollIndicator = FALSE;
    MYmainScroll1.showsHorizontalScrollIndicator = FALSE;

    MYmainScroll2 = [[UIScrollView alloc] initWithFrame:CGRectMake(ScreenWidth*2,0, ScreenWidth, ScreenHeight-320)];
    [MYmainScroll2 setBackgroundColor: zuiqianhuicolor];
    MYmainScroll2.delegate = self;
    MYmainScroll2.userInteractionEnabled = YES;
    MYmainScroll2.scrollEnabled = YES;
    MYmainScroll2.showsVerticalScrollIndicator = FALSE;
    MYmainScroll2.showsHorizontalScrollIndicator = FALSE;

    self.scrollView = [[UIScrollView alloc] init];
    self.scrollView.frame = CGRectMake(0, 230+64, ScreenWidth, ScreenHeight-220-44);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    
    
    NSArray * ads = @[@"",@"",@""];
    
    for (int h = 0 ; h < ads.count; h++) {
        UIImage * image = [UIImage imageNamed:ads[h]];
        UIImageView * imageView = [[UIImageView alloc] initWithImage:image];
        CGRect frame = self.scrollView.frame;
        frame.origin.x = h * frame.size.width;
        frame.origin.y = 0;
        imageView.frame = frame;
        
        [self.scrollView addSubview:imageView];
        
    }
    
    CGSize size = self.scrollView.frame.size;
    size.width *= 3;
    self.scrollView.contentSize = size;
    self.scrollView.delegate = self;
    
    
    [self.scrollView addSubview:MYmainScroll];
    [self.scrollView addSubview:MYmainScroll1];
    [self.scrollView addSubview:MYmainScroll2];
    [self jiazai];
    
    
    
    
    
    
    
    
    
    
}
-(void)closeKeyBoad
{
    [i12 removeFromSuperview];
    saveAccount=NO;
     [shoushiview removeFromSuperview];
}
    
-(void)jiazai{
    

    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString* Token1 = [user1 objectForKey:@"tokenId"];
    if (Token1 ==nil) {
        Token1=@"dd";
    }
    NSMutableDictionary *param1 = [NSMutableDictionary new];
    [param1 setValue:Token1 forKey:@"tokenId"];
    [param1 setValue:commdity.orderId forKey:@"ckvId"];
    
     [param1 setValue:@"gain" forKey:@"ckStatus"];
    
    
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param1 success:^(BOOL isSuccess, SeverData *severDataDict) {
    if (isSuccess) {
            NSLog(@"-----------%@", severDataDict.dataDict);
        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss=[[NSMutableArray alloc]init];
                arrrss=[severDataDict.dataDict objectForKey:@"DataLine"];
    
            
    
    
    
       

//    view3=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
//    view3.backgroundColor=[UIColor whiteColor];
//    [MYmainScroll addSubview:view3];
//   
//                
//    UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
//    shangpingxinxi.text=@"商品信息";
//    shangpingxinxi.textColor=[UIColor blackColor];
//    shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
//    [view3 addSubview:shangpingxinxi];
//    UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(15, 43.65, ScreenWidth-30, 0.35)];
//    lineL.backgroundColor=qianhuicolor;
//    [view3 addSubview:lineL];
    
    NSLog(@"%@",arrrss);
    if (arrrss.count>0) {
        
        for (int i = 0; i<arrrss.count; i++) {
            
            shangpingView = [[shangpingview alloc]initWithFrame:CGRectMake(0, (120*i), ScreenWidth, 120)];
            shangpingView.backgroundColor=[UIColor whiteColor];
            [shangpingView.headImageFull setImageWithURL:[[arrrss objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@""]];
            [shangpingView.headImageFull.layer setCornerRadius:6.0];
            [shangpingView.headImageFull.layer setBorderWidth:0.3];
            [shangpingView.headImageFull.layer setMasksToBounds:YES];
            CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
            CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
            [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
            
            shangpingView.itemName.text=[NSString stringWithFormat:@"%@%@",[[arrrss objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss objectAtIndex:i] objectForKey:@"itemName"]];
            
            shangpingView.quantity.text=[NSString stringWithFormat:@"数量 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]];
            
            NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"数量 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]]];
            
            [AttributedStr1 addAttribute:NSFontAttributeName
             
                                   value:[UIFont systemFontOfSize:14.0]
             
                                   range:NSMakeRange(0, 3)];
            
            [AttributedStr1 addAttribute:NSForegroundColorAttributeName
             
                                   value:zhonghuiColor
             
                                   range:NSMakeRange(0, 3)];
            
            
            shangpingView.quantity.attributedText = AttributedStr1;
            
            
            NSNumber*Total =[[arrrss objectAtIndex:i] objectForKey:@"salePrice"];
            
            NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
            [numberFormatter setPositiveFormat:@"###,##0.00;"];
            NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
            shangpingView.dealPrice.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
            shangpingView.dealPrice.textColor=hongsecolor;
            shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss objectAtIndex:i] objectForKey:@"specName"]];
            NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@",formattedNumberString]];
            
            [AttributedStr12 addAttribute:NSFontAttributeName
             
                                    value:[UIFont systemFontOfSize:contenfot]
             
                                    range:NSMakeRange(0, 1)];
            
            [AttributedStr12 addAttribute:NSForegroundColorAttributeName
             
                                    value:hongsecolor
             
                                    range:NSMakeRange(0, 1)];
            
            
            shangpingView.dealPrice.attributedText = AttributedStr12;
           
            if (i==arrrss.count-1) {
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
                lineLabel1.backgroundColor=qianhuicolor;
                [shangpingView addSubview:lineLabel1];
            }else{
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
                lineLabel1.backgroundColor=qianhuicolor;
                [shangpingView addSubview:lineLabel1];
                
                
            }
            
            [MYmainScroll addSubview:shangpingView];
            
        }
        MYmainScroll.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
    }

            
        
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
  
    
    
   
    
    
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    NSString* Token2 = [user2 objectForKey:@"tokenId"];
    if (Token2 ==nil) {
        Token2=@"dd";
    }
    NSMutableDictionary *param2 = [NSMutableDictionary new];
    [param2 setValue:Token2 forKey:@"tokenId"];
    [param2 setValue:commdity.orderId forKey:@"ckvId"];
    
    [param2 setValue:@"loss" forKey:@"ckStatus"];
    
    
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param2 success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"======-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss1=[[NSMutableArray alloc]init];
                arrrss1=[severDataDict.dataDict objectForKey:@"DataLine"];
                
             
//                view3=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
//                view3.backgroundColor=[UIColor whiteColor];
//                [MYmainScroll1 addSubview:view3];
//                
//                
//                UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
//                shangpingxinxi.text=@"商品信息";
//                shangpingxinxi.textColor=[UIColor blackColor];
//                shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
//                [view3 addSubview:shangpingxinxi];
//                UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(15, 43.65, ScreenWidth-30, 0.35)];
//                lineL.backgroundColor=qianhuicolor;
//                [view3 addSubview:lineL];
                
                NSLog(@"%@",arrrss1);
                if (arrrss1.count>0) {
                    
                    for (int i = 0; i<arrrss1.count; i++) {
                        
                        shangpingView = [[shangpingview alloc]initWithFrame:CGRectMake(0, (120*i), ScreenWidth, 120)];
                        shangpingView.backgroundColor=[UIColor whiteColor];
                        [shangpingView.headImageFull setImageWithURL:[[arrrss1 objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@""]];
                        [shangpingView.headImageFull.layer setCornerRadius:6.0];
                        [shangpingView.headImageFull.layer setBorderWidth:0.3];
                        [shangpingView.headImageFull.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
                        [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
                        
                        shangpingView.itemName.text=[NSString stringWithFormat:@"%@%@",[[arrrss1 objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss1 objectAtIndex:i] objectForKey:@"itemName"]];
                        
                        shangpingView.quantity.text=[NSString stringWithFormat:@"数量 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"quantity"]];
                        
                        NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"数量 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"quantity"]]];
                        
                        [AttributedStr1 addAttribute:NSFontAttributeName
                         
                                               value:[UIFont systemFontOfSize:contenfot]
                         
                                               range:NSMakeRange(0, 3)];
                        
                        [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                         
                                               value:zhonghuiColor
                         
                                               range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.quantity.attributedText = AttributedStr1;
                        
                        
                        NSNumber*Total =[[arrrss1 objectAtIndex:i] objectForKey:@"salePrice"];
                        
                        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                        [numberFormatter setPositiveFormat:@"###,##0.00;"];
                        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
                        shangpingView.dealPrice.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
                        shangpingView.dealPrice.textColor=hongsecolor;
                        shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss1 objectAtIndex:i] objectForKey:@"specName"]];
                        NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@",formattedNumberString]];
                        
                        [AttributedStr12 addAttribute:NSFontAttributeName
                         
                                                value:[UIFont systemFontOfSize:contenfot]
                         
                                                range:NSMakeRange(0, 1)];
                        
                        [AttributedStr12 addAttribute:NSForegroundColorAttributeName
                         
                                                value:hongsecolor
                         
                                                range:NSMakeRange(0, 1)];
                        
                        
                        shangpingView.dealPrice.attributedText = AttributedStr12;
                        if (i==arrrss1.count-1) {
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
                            lineLabel1.backgroundColor=qianhuicolor;
                            [shangpingView addSubview:lineLabel1];
                        }else{
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
                            lineLabel1.backgroundColor=qianhuicolor;
                            [shangpingView addSubview:lineLabel1];
                            
                            
                        }
                        
                        [MYmainScroll1 addSubview:shangpingView];
                        
                    }
                    MYmainScroll1.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
                }
          
                           }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
  
    
    NSUserDefaults *user3 = [NSUserDefaults standardUserDefaults];
    NSString* Token3 = [user3 objectForKey:@"tokenId"];
    if (Token3 ==nil) {
        Token3=@"dd";
    }
    NSMutableDictionary *param3 = [NSMutableDictionary new];
    [param3 setValue:Token3 forKey:@"tokenId"];
    [param3 setValue:commdity.orderId forKey:@"ckvId"];
    
    [param3 setValue:@"balance" forKey:@"ckStatus"];
    
        NSLog(@"-----------%@", param3);
    
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param3 success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"======-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss2=[[NSMutableArray alloc]init];
                arrrss2=[severDataDict.dataDict objectForKey:@"DataLine"];
                
                
//                view3=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
//                view3.backgroundColor=[UIColor whiteColor];
//                [MYmainScroll2 addSubview:view3];
//                
//                
//                UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
//                shangpingxinxi.text=@"商品信息";
//                shangpingxinxi.textColor=[UIColor blackColor];
//                shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
//                [view3 addSubview:shangpingxinxi];
//                UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(15, 43.65, ScreenWidth-30, 0.35)];
//                lineL.backgroundColor=qianhuicolor;
//                [view3 addSubview:lineL];
                
                NSLog(@"%@",arrrss2);
                if (arrrss2.count>0) {
                    
                    for (int i = 0; i<arrrss2.count; i++) {
                        
                        shangpingView = [[shangpingview alloc]initWithFrame:CGRectMake(0, (120*i), ScreenWidth, 120)];
                        shangpingView.backgroundColor=[UIColor whiteColor];
                        [shangpingView.headImageFull setImageWithURL:[[arrrss2 objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@""]];
                        [shangpingView.headImageFull.layer setCornerRadius:6.0];
                        [shangpingView.headImageFull.layer setBorderWidth:0.3];
                        [shangpingView.headImageFull.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
                        [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
                        
                        shangpingView.itemName.text=[NSString stringWithFormat:@"%@%@",[[arrrss2 objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss2 objectAtIndex:i] objectForKey:@"itemName"]];
                        
                        shangpingView.quantity.text=[NSString stringWithFormat:@"数量 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"quantity"]];
                        
                        NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"数量 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"quantity"]]];
                        
                        [AttributedStr1 addAttribute:NSFontAttributeName
                         
                                               value:[UIFont systemFontOfSize:15.0]
                         
                                               range:NSMakeRange(0, 3)];
                        
                        [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                         
                                               value:zhonghuiColor
                         
                                               range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.quantity.attributedText = AttributedStr1;
                        
                        
                        NSNumber*Total =[[arrrss2 objectAtIndex:i] objectForKey:@"salePrice"];
                        
                        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                        [numberFormatter setPositiveFormat:@"###,##0.00;"];
                        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
                        shangpingView.dealPrice.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
                        shangpingView.dealPrice.textColor=hongsecolor;
                        shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss2 objectAtIndex:i] objectForKey:@"specName"]];
                        NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@",formattedNumberString]];
                        
                        [AttributedStr12 addAttribute:NSFontAttributeName
                         
                                                value:[UIFont systemFontOfSize:contenfot]
                         
                                                range:NSMakeRange(0, 1)];
                        
                        [AttributedStr12 addAttribute:NSForegroundColorAttributeName
                         
                                                value:hongsecolor
                         
                                                range:NSMakeRange(0, 1)];
                        
                        
                        shangpingView.dealPrice.attributedText = AttributedStr12;
                        
                        if (i==arrrss2.count-1) {
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
                            lineLabel1.backgroundColor=qianhuicolor;
                            [shangpingView addSubview:lineLabel1];
                        }else{
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
                            lineLabel1.backgroundColor=qianhuicolor;
                            [shangpingView addSubview:lineLabel1];
                            
                            
                        }
                       
                        [MYmainScroll2 addSubview:shangpingView];
                        
                    }
                    MYmainScroll2.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
                }
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];

//    [self addd];

}


- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
    
    
    if (self.scrollView.bounds.origin.x==0) {
       
        
        [bu setTitleColor:backColor forState:UIControlStateNormal];
        [bu1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [bu2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        
        self.moveImage.frame = CGRectMake(0, 48.5, ScreenWidth/3, 1.5);
    }
    
    if (self.scrollView.bounds.origin.x==ScreenWidth) {
        
        
        [bu1 setTitleColor:backColor forState:UIControlStateNormal];
        [bu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        
        [bu2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        self.moveImage.frame = CGRectMake(ScreenWidth/3, 48.5, ScreenWidth/3, 1.5);
       }
    
    if (self.scrollView.bounds.origin.x==ScreenWidth*2) {
        
        
        [bu1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [bu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [bu2 setTitleColor:backColor forState:UIControlStateNormal];
       self.moveImage.frame = CGRectMake(ScreenWidth/3*2, 48.5, ScreenWidth/3, 1.5);
    }
    
    
    
}

-(void)queren:(UIButton*)sender{
    
    UIAlertView* alts = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"是否确认盘点？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [alts show];
    
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 1) {
        
        
        NSUserDefaults *user3 = [NSUserDefaults standardUserDefaults];
        NSString* Token3 = [user3 objectForKey:@"tokenId"];
        if (Token3 ==nil) {
            Token3=@"dd";
        }
        NSMutableDictionary *param3 = [NSMutableDictionary new];
        [param3 setValue:Token3 forKey:@"tokenId"];
        [param3 setValue:commdity.orderId forKey:@"ckvId"];
        
        
        NSLog(@"-----------%@", param3);
        
        [HttpRequest requestData:@"Business/CheckVouch/Confirm" params:param3 success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                NSLog(@"======-----------%@", severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [self showAlertMessage:@"盘点确认成功"];
                    [tureBtn removeFromSuperview];
                    tureBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
                    [tureBtn setTitle:@"盘点确认" forState:UIControlStateNormal];
                    tureBtn.backgroundColor=zhonghuiColor;
                    [isActive setTextColor:luseColor];
                    isActive.text=@"已确认";
                    
                    commdity.payStatuss=@"Y";
                    
                    
                    
                    if ([commdity.payStatuss isEqualToString:@"Y"]) {
                        [sxBtn removeFromSuperview];
                        sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
                        [sxBtn setTitle:@"   " forState:UIControlStateNormal];
                        [sxBtn setTitleColor:luseColor forState:UIControlStateNormal];
                        sxBtn.titleLabel.font=[UIFont systemFontOfSize:28];
                        [sxBtn addTarget:self action:@selector(xuanze:) forControlEvents:UIControlEventTouchUpInside];
                        UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
                        self.navigationItem.rightBarButtonItem = myBtnBtn;
                    }
                    //        [tureBtn addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
                    
                    [tureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                    [self.view addSubview:tureBtn];
                    
                    
                    
                    
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
            
        }];

        
    }
    
}


-(void)addd{
    if ([[commdity.Dict objectForKey:@"ckvStatus"]isEqualToString:@"N"]) {
        
        
        tureBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
        [tureBtn setTitle:@"盘点确认" forState:UIControlStateNormal];
        tureBtn.backgroundColor=luseColor;
        [tureBtn addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
        
        [tureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.view addSubview:tureBtn];
        
    }else{
        
        tureBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
        [tureBtn setTitle:@"盘点确认" forState:UIControlStateNormal];
        tureBtn.backgroundColor=zhonghuiColor;
        //        [tureBtn addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
        
        [tureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.view addSubview:tureBtn];
        
        
        
    }

    self.customTabBar = [[UIView alloc]initWithFrame:CGRectMake(0,360/2+64, ScreenWidth, 50.5)];
    self.customTabBar .backgroundColor=[UIColor whiteColor];
    self.customTabBar.layer.borderWidth = 0.35;
    self.customTabBar.layer.borderColor = qianhuicolor.CGColor;

    //添加移动的图片
    self.moveImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tabbar_slider.png"]];
    self.moveImage.backgroundColor=backColor;
    self.moveImage.frame = CGRectMake(0, 0, ScreenWidth/3, 1.5);
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2;
    [self.moveImage setCenter:CGPointMake(sliderImageViewCenterX, 49.5)];
    [self.customTabBar addSubview:_moveImage];
    [self.view addSubview:self.customTabBar];
    
    
    bu=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth/3, 50)];
    [bu setTitle:[NSString stringWithFormat:@"盘盈%@件",  [commdity.Dict objectForKey:@"gain"]]   forState:UIControlStateNormal];
    [bu setTitleColor:backColor forState:UIControlStateNormal];
    bu .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu addTarget:self action:@selector(tabBarItemClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu];
    
    bu1=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3, 0, ScreenWidth/3, 50)];
  
    [bu1 setTitle:[NSString stringWithFormat:@"盘亏%@件",  [commdity.Dict objectForKey:@"loss"]]   forState:UIControlStateNormal];

    [bu1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    bu1 .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu1 addTarget:self action:@selector(tabBarItemClicked1) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu1];
    
    bu2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*2, 0, ScreenWidth/3,50)];
    [bu2 setTitle:[NSString stringWithFormat:@"盘存%@件",  [commdity.Dict objectForKey:@"balance"]]   forState:UIControlStateNormal];
    [bu2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    bu2 .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu2 addTarget:self action:@selector(tabBarItemClicked2) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu2];
    
}

-(void)tabBarItemClicked{
    //更换moveImage的位置
    
    [bu1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [bu setTitleColor:backColor forState:UIControlStateNormal];
    [bu2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (0 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        
        
        
    }];
    
    [self.scrollView setContentOffset:CGPointMake(0, 0) ];
    self.scrollView.bouncesZoom=NO;
}





-(void)tabBarItemClicked1{
    //更换moveImage的位置
    [bu1 setTitleColor:backColor forState:UIControlStateNormal];
    [bu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [bu2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (1 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        
        
        
    }];
    
    [self.scrollView setContentOffset:CGPointMake(ScreenWidth, 0) ];
    self.scrollView.bouncesZoom=NO;
}


-(void)tabBarItemClicked2{
    //更换moveImage的位置
    [bu1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [bu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [bu2 setTitleColor:backColor forState:UIControlStateNormal];
    
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (2 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        
        
        
    }];
    
    [self.scrollView setContentOffset:CGPointMake(ScreenWidth*2, 0) ];
    self.scrollView.bouncesZoom=NO;
}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}


@end
